import 'dart:core';
import 'package:flutter/material.dart';

// ignore: must_be_immutable

/// [tapCallback]:箭头点击回调
/// [content]:文本
/// [title]:标题
/// [placeholder]:占位符
/// [isLine]:是否底部有分割线
/// [allowEmpty]:是否必填，false时显示必填辨识
class PulldownSelectItemWidget extends StatelessWidget {

  final VoidCallback tapCallback;
  final String  content;
  final String  title;
  final String  placeholder;
  final bool    isLine;
  final bool    allowEmpty;

  PulldownSelectItemWidget({this.title,this.content="",this.placeholder,this.isLine,this.tapCallback, this.allowEmpty = true});
  @override
  Widget build(BuildContext context) {
    return buildWidget(context);
  }

  Widget buildWidget(BuildContext context) {
    return Container(
        color: Colors.white,
        child: InkWell(
          child: Column(
            children: <Widget>[
              Container(
                height: 48,
                padding: EdgeInsets.only(right: 16),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                    allowEmpty ? SizedBox(width: 16,):Container(
                      width: 16,
                      alignment: Alignment.center,
                      child: Text('＊', style: TextStyle(color: Color(0xFF3DBCC6),fontSize: 6),),
                    ),
                    Text(title??"",style: TextStyle(
                      color: Color(0xff666666),
                      fontSize: 14,
                    ),),
                    Spacer(),
                    Text(content.length > 0 ? content : placeholder,
                      textAlign: TextAlign.right,
                      style: TextStyle(color:content.length > 0 ? Color(0xff333333): Color(0xff999999),fontSize: 14,fontWeight: FontWeight.normal),
                    ),
                    SizedBox(width: 3,),
                    Image.asset('images/dk_form/right_arrow.png', width: 11, height: 11, fit: BoxFit.contain,),
                  ],
                ),
              ),
              Container(
                padding: EdgeInsets.only(left: 16),
                child: Offstage(
                  offstage: !isLine,
                  child: Container(
                    height: 0.5,
                    color: Color(0xffebebeb),
                  ),
                ),
              ),
            ],
          ),
          onTap: (){
            if(tapCallback!= null) {
              tapCallback();
            }
          },
        )
    );
  }
}



